package com.myzk.config;

import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;

/**
 * @author: LI-CI-GAO
 * 作者: licigao
 * 日期: 2021/8/31  19:41
 * 描述:
 */
public class MyWatcher implements Watcher {
    @Override
    public void process(WatchedEvent event) {

        if(event.getType().getIntValue()==Event.EventType.NodeCreated.getIntValue()){
            System.out.println("=======新创建一个节点======");
        }else if(event.getType().getIntValue()==Event.EventType.NodeDataChanged.getIntValue()){
            System.out.println("=======节点的数据发生变更======");
        }else if(event.getType().getIntValue()==Event.EventType.NodeChildrenChanged.getIntValue()){
            System.out.println("=======子节点发生变更======");
        }else if(event.getType().getIntValue()==Event.EventType.NodeDeleted.getIntValue()){
            System.out.println("=======节点被删除======");
        }else if(event.getType().getIntValue()==Event.EventType.None.getIntValue()){
            System.out.println("=======None======"+event.getPath());
        }

    }
}
